{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2f599348",
   "metadata": {},
   "source": [
    "# Author:Jiezhi\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e3547354",
   "metadata": {},
   "source": [
    "### 登录系统（数据库数据）\n",
    "\n",
    "```\n",
    " 优化 ： 1. 输入不正确时继续输入。 2.设置输入失败的次数\n",
    "\n",
    " while True + count 计数器  VS  for循环 + range()\\\n",
    " while True + 结束条件\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "598b2a3e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "无论世事变改,还是越来越爱... 10\n",
      "无论世事变改,还是越来越爱... 20\n",
      "无论世事变改,还是越来越爱... 30\n",
      "无论世事变改,还是越来越爱... 40\n",
      "无论世事变改,还是越来越爱... 50\n",
      "无论世事变改,还是越来越爱... 60\n",
      "无论世事变改,还是越来越爱... 70\n",
      "无论世事变改,还是越来越爱... 80\n",
      "无论世事变改,还是越来越爱... 90\n",
      "无论世事变改,还是越来越爱... 100\n"
     ]
    }
   ],
   "source": [
    "count = 0\n",
    "while True:\n",
    "    # count = count+1\n",
    "    count +=10\n",
    "    print(\"无论世事变改,还是越来越爱...\",count)\n",
    "    if count == 100:\n",
    "        break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "534a60d1",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 简单的数据结构有 ： 数值和字符串\n",
    "# 模拟数据库数据 复杂的数据结构：\n",
    "user_data = [\"jiezhi\",\"keyan\",\"xaingqing\",\"guohao\"]\n",
    "password_data = [\"123456\",\"436432\",\"47382\"]\n",
    "\n",
    "count = 10\n",
    "while True:\n",
    "    count -= 1\n",
    "    # 用户输入数据\n",
    "    username = input(\"请输入您的账号：\")\n",
    "    password = input(\"请输入您的密码：\")\n",
    "    # 判断账号是否正确\n",
    "    if user_data == username:\n",
    "        if password_data == password:\n",
    "            # 占位符%s\n",
    "            print(\"欢迎%s登录系统使用~\"%(username))\n",
    "            break\n",
    "        else:\n",
    "            if count == 0:\n",
    "                print(\"你都输入十次了，还不对，笨死了~~~，别输了，5分钟后再来\")\n",
    "                break\n",
    "            else:\n",
    "                print(\"您输入的账号或密码不正确，请重新输入，您还有\",count,\"次机会~加油~\")\n",
    "    else:\n",
    "        if count == 0:\n",
    "            print(\"你都输入十次了，还不对，笨死了~~~，别输了，5分钟后再来\")\n",
    "            break\n",
    "        else:\n",
    "            print(\"您输入的账号或密码不正确，请重新输入，您还有\",count,\"次机会~加油~\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "403be51d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# for+range（）的使用\n",
    "# 课本案例\n",
    "word = \"bottles\"\n",
    "\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num,word,\"of beer on the wall.\")\n",
    "    print(beer_num,word,\"of beer\")\n",
    "    print(\"Take one down.\")\n",
    "    print(\"Pass it around\")\n",
    "    # 1. 拿不走了，没有足够的啤酒了\n",
    "    if beer_num == 1:\n",
    "        print(\"没有足够的bottles在wall上了\")\n",
    "    # 2. 还有足够的啤酒\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"bottle\"\n",
    "            print(new_num,word,\"of beer on the wall.\")\n",
    "    # 空行\n",
    "    print()\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
